<?php

/**
 * Villages form base class.
 *
 * @method Villages getObject() Returns the current form's model object
 *
 * @package    costabravasfr
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseVillagesForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'             => new sfWidgetFormInputHidden(),
      'nomVillage'     => new sfWidgetFormInputText(),
      'descPreVillage' => new sfWidgetFormTextarea(),
      'descVillage'    => new sfWidgetFormTextarea(),
      'population'     => new sfWidgetFormInputText(),
      'superficie'     => new sfWidgetFormInputText(),
      'geolatitud'     => new sfWidgetFormInputText(),
      'geolongitud'    => new sfWidgetFormInputText(),
      'visible'        => new sfWidgetFormInputCheckbox(),
      'created_by'     => new sfWidgetFormTextarea(),
      'created_at'     => new sfWidgetFormDateTime(),
      'updated_by'     => new sfWidgetFormTextarea(),
      'updated_at'     => new sfWidgetFormDateTime(),
      'slug'           => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'             => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'nomVillage'     => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'descPreVillage' => new sfValidatorString(array('max_length' => 500, 'required' => false)),
      'descVillage'    => new sfValidatorString(array('max_length' => 3000, 'required' => false)),
      'population'     => new sfValidatorNumber(array('required' => false)),
      'superficie'     => new sfValidatorNumber(array('required' => false)),
      'geolatitud'     => new sfValidatorNumber(array('required' => false)),
      'geolongitud'    => new sfValidatorNumber(array('required' => false)),
      'visible'        => new sfValidatorBoolean(array('required' => false)),
      'created_by'     => new sfValidatorString(array('required' => false)),
      'created_at'     => new sfValidatorDateTime(),
      'updated_by'     => new sfValidatorString(array('required' => false)),
      'updated_at'     => new sfValidatorDateTime(),
      'slug'           => new sfValidatorString(array('max_length' => 255, 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'Villages', 'column' => array('nomVillage'))),
        new sfValidatorDoctrineUnique(array('model' => 'Villages', 'column' => array('slug'))),
      ))
    );

    $this->widgetSchema->setNameFormat('villages[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Villages';
  }

}
